package com.nebula.mapper;

import com.github.pagehelper.Page;
import com.nebula.annotation.AutoFill;
import com.nebula.dto.DishPageQueryDTO;
import com.nebula.entity.Dish;
import com.nebula.enumeration.OperationType;
import com.nebula.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);


    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    void delete(List<Long> ids);

    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);


    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> list(Dish dish);

    Integer checkStatusByIds(List<Long> dishIds);

    Integer countByMap(Map map);
}
